package com.hospital.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hospital.service.BackgroundService;
import com.hospital.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/background")
@CrossOrigin(origins = "*",maxAge = 3600)
public class BackgroundController {
    @Autowired
    private BackgroundService backgroundService;

//    @Cacheable(value = "background",key = "#root.methodName")
    @GetMapping("/list")
    public R list(){
        return R.ok().put("data", backgroundService.list());
    }

//    @GetMapping("selectPage")
    public R selectPage(@RequestParam(defaultValue = "1") int current,
                        @RequestParam(defaultValue = "3") int size) {
        return R.ok().put("list",backgroundService.page(new Page<>(current,size)));
    }
}
